class PSAIControllerChaser extends PSAIControllerBase;

// Just aim at the player 
auto state Attack
{
	event Tick(float DeltaTime)
	{
	}

Begin:
	// Automatically set player as target
	Target = PSPawnDidrik(GetALocalPlayerController().Pawn);
	PSPawn(Pawn).CurrentPosture = PSPawn(Pawn).EPosture.POSTURE_Checking;
	Focus = Target;

	// If the enemy is a patroller set the starting node
	if(PatrolNodes.Length > 0)
	{
		NextPatrolNodeIndex = 0;
		GotoState('TakePosition');
	}
}

state TakePosition
{

Begin:
	PSPawn(Pawn).CurrentPosture = PSPawn(Pawn).EPosture.POSTURE_Running;
	PSPawnEnemyRandom(Pawn).SetMovingSpeed(PSPawnEnemyRandom(Pawn).EMovingSpeed.SPEED_Running);
	NextNode = PatrolNodes[NextPatrolNodeIndex];

    if(FindNavMeshPath(true))
	{
		NavigationHandle.SetFinalDestination(NextNode.Location);

		while(!Pawn.ReachedDestination(NextNode))
		{
			// Final location is reachable, so go straight
			if(NavigationHandle.ActorReachable(NextNode))
			{
				MoveToward(NextNode);
			}
			// Final location is not reachable, so find a way to get it
			else 
			{		
				if(NavigationHandle.GetNextMoveLocation(TempDest, Pawn.GetCollisionRadius()))
				{
					// Avoid infinite loop due to path finding problems
					if(PreviousLocation == Pawn.Location)
					{
						break;
					}

					PreviousLocation = Pawn.Location;

					MoveTo(TempDest);
				}
			}
		}
	}

}

DefaultProperties
{
	AI_DEBUG_ENABLED=false
}
